// HTTP 相关类型定义

// 通用API响应格式
export interface ApiResponse<T = any> {
  code: number
  data: T
  message: string
  success: boolean
  timestamp?: number
}

// 分页参数
export interface PageParams {
  page: number
  pageSize: number
  total?: number
}

// 分页响应数据
export interface PageResponse<T = any> {
  list: T[]
  pagination: {
    page: number
    pageSize: number
    total: number
    totalPages: number
  }
}

// 请求方法常量
export const RequestMethod = {
  GET: 'GET',
  POST: 'POST',
  PUT: 'PUT',
  DELETE: 'DELETE',
  PATCH: 'PATCH'
} as const

// 请求内容类型常量
export const ContentType = {
  JSON: 'application/json;charset=UTF-8',
  FORM_URLENCODED: 'application/x-www-form-urlencoded;charset=UTF-8',
  FORM_DATA: 'multipart/form-data',
  TEXT: 'text/plain;charset=UTF-8'
} as const

// 文件上传相关
export interface UploadFile {
  name: string
  size: number
  type: string
  file: File
}

export interface UploadResponse {
  url: string
  name: string
  size: number
  type: string
}

// 业务相关类型定义示例
export interface User {
  id: number
  username: string
  email: string
  avatar?: string
  createTime: string
  updateTime: string
}

export interface SwiperItem {
  id: number
  title: string
  image: string
  link?: string
  description?: string
  sort: number
  status: number
}

export interface TravelPost {
  id: number
  title: string
  content: string
  images: string[]
  author: User
  location: string
  tags: string[]
  viewCount: number
  likeCount: number
  createTime: string
  updateTime: string
}

// 登录相关
export interface LoginParams {
  username: string
  password: string
  captcha?: string
}

export interface LoginResponse {
  token: string
  refreshToken: string
  userInfo: User
  permissions: string[]
}

// 搜索相关
export interface SearchParams {
  keyword: string
  type?: string
  page?: number
  pageSize?: number
  sortBy?: string
  sortOrder?: 'asc' | 'desc'
}

export interface SearchResponse<T = any> {
  results: T[]
  total: number
  page: number
  pageSize: number
  keyword: string
}
